/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 8 - Impacts on Women's Educational Attainment and Labor-Force Participation
=========================================================================*/

use "$data/Final_Medellin_SisbenIV.dta", replace

	
	
global outcomes No_Educa  Basica_Primaria Secundaria Media Superior Trabajando Trabajador_Independiente Empleado_Domestico Empleado_Particular Empleado_Gobierno  Empleado_NoRemuneracion Otro_Empleado Buscando_Trabajo Oficios_Hogar Sin_Actividad Discapacitado  Estudia  


mat a=J(17,4,.)
matrix rownames a =  $outcomes


local i=1
foreach var in $outcomes    {
	sum `var' if Niega==0
	mat 	a[`i',1] = r(mean)

	ivreghdfe `var'         (Niega=Mujer_Ponente)  , abs(oficina#time) cluster(id_juez) savefirst

	mat 	a[`i',2]  = _b[Niega]
	mat 	a[`i',3] = _se[Niega]

	mat 	a[`i',4] =e(N)


		
	local i=`i'+1
	}


mat lis a

	svmat2 a, rnames(outcome)
	
	drop if outcome==""
	
	rename a1 mean_nondenied
	rename a2 coef_femaleIV
	rename a3 se_femaleIV
	rename a4 N_femaleIV	
	
	
	keep outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	order outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 8", modify) 
